package com.brave.manager.service;

import com.brave.manager.dao.TeacherDao;
import com.brave.manager.domian.Teacher;

public class TeacherService {
    TeacherDao TeacherDao = new TeacherDao();
    public boolean isExists(String id) {
        Teacher[] teas = TeacherDao.findAllTeacher();
        boolean Exists = false;
        for (int i = 0; i < teas.length; i++) {
            Teacher tea = teas[i];
            if(tea != null && tea.getId().equals(id)){
                Exists =true;
                break;
            }
        }
        return Exists;
    }

    public boolean addTeacher(Teacher tea) {
        return TeacherDao.addStudnet(tea);
    }

    public Teacher[] findAllTeacher() {
        Teacher[] teas = TeacherDao.findAllTeacher();
        boolean res = false;
        for (int i = 0; i < teas.length; i++) {
            Teacher tea = teas[i];
            if(tea != null){
                res = true;
                break;
            }
        }
        if (res){
            return teas;
        }else {
            return null;
        }
    }

    public void deleteTeacher(String id) {
        TeacherDao.deleteTeacher(id);
    }

    public void updateTeacher(String id, Teacher tea) {
        TeacherDao.updateTeacher(id,tea);
    }
}
